package it.learn.kafka.producer81;

import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.core.env.Environment;
import org.springframework.kafka.core.KafkaTemplate;

import java.io.PrintStream;

@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = "it.learn.kafka")
public class Producer8081App {

    public static void main(String[] args) {
        System.out.println("args = " + args);
        SpringApplication application = new SpringApplication(Producer8081App.class);
        // application.setBannerMode(Banner.Mode.OFF);
        application.setBanner(new Banner() {
            @Override
            public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
                System.out.println("我是你大爷。。。。。");
                System.out.println("我是你大爷。。。。。");
                System.out.println("我是你大爷。。。。。");
            }
        });
        application.run(args);
    }

    // @Bean
    public ApplicationRunner runner(KafkaTemplate<String, String> template) {
        return args -> {
            template.send("topic1", "test");
            template.send("topic1", "test2");
            System.out.println("消息发送成功......");
        };
    }

}
